In [1]:
%load_ext autoreload
%autoreload 2
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import pylab
import chopstacks as cs
In [2]:
%matplotlib inline
In [3]:
#original data
nwav=1000
ws=400.0
we=1000.0
wav=np.linspace(ws,we,nwav)
wavw=cs.buildwall(wav)
f=np.random.normal(0.0,1.0,nwav)+(np.linspace(1.0,4.0,nwav))**2.0
In [6]:
# logarithm resampling with R=100
R=100.0
hx, hxw, hf=cs.setanalogbin(wav,wavw,f,R,0)
In [7]:
#checl preservation
cs.check_preservation(wavw,f,hxw,hf)
In [8]:
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(wav,f,color="blue")
ax.plot(hx,hf,"o",color="red")
plt.xlabel("$x$")
plt.ylabel("$f$ (blue), $\hat{f}$ (red)")
plt.show()
In [9]:
#oversampling
R=10000.0
hx, hxw, hf=cs.setanalogbin(wav,wavw,f,R,0)
cs.check_preservation(wavw,f,hxw,hf)
In [10]:
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(wav,f,color="blue")
ax.plot(hx,hf,"o",color="red")
plt.xlabel("$x$")
plt.ylabel("$f$ (blue), $\hat{f}$ (red)")
plt.show()
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(wav,f,color="blue")
ax.plot(hx,hf,"o",color="red")
pylab.xlim(540,550)
pylab.ylim(0,6)
plt.xlabel("$x$")
plt.ylabel("$f$ (blue), $\hat{f}$ (red)")
plt.show()
In [ ]: